home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / windows / ocx / ipack.exe / GETTIME.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-08-19  |  3.0 KB  |  103 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Time Control Sample"
  4.    ClientHeight    =   3570
  5.    ClientLeft      =   1530
  6.    ClientTop       =   2370
  7.    ClientWidth     =   3015
  8.    Height          =   3975
  9.    Left            =   1470
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3570
  12.    ScaleWidth      =   3015
  13.    Top             =   2025
  14.    Width           =   3135
  15.    Begin VB.CheckBox Check1 
  16.       Caption         =   "Blocking"
  17.       Height          =   195
  18.       Left            =   105
  19.       TabIndex        =   1
  20.       Top             =   600
  21.       Value           =   1  'Checked
  22.       Width           =   1230
  23.    End
  24.    Begin VB.CommandButton Command1 
  25.       Caption         =   "Get Time"
  26.       Height          =   375
  27.       Left            =   1680
  28.       TabIndex        =   0
  29.       Top             =   600
  30.       Width           =   1110
  31.    End
  32.    Begin VB.Label Label3 
  33.       Caption         =   "You must be connected to the Internet through a TCP/IP connection for this program to work."
  34.       Height          =   615
  35.       Left            =   120
  36.       TabIndex        =   4
  37.       Top             =   2880
  38.       Width           =   2775
  39.    End
  40.    Begin VB.Label Label2 
  41.       Caption         =   $"gettime.frx":0000
  42.       Height          =   1575
  43.       Left            =   120
  44.       TabIndex        =   3
  45.       Top             =   1080
  46.       Width           =   2775
  47.    End
  48.    Begin TimeLib.Time Time1 
  49.       Left            =   2520
  50.       Top             =   0
  51.       _Version        =   327680
  52.       _ExtentX        =   847
  53.       _ExtentY        =   847
  54.       _StockProps     =   0
  55.       Blocking        =   0   'False
  56.       Host            =   "mit.edu"
  57.    End
  58.    Begin VB.Label Label1 
  59.       BackColor       =   &H00FFFFFF&
  60.       Height          =   225
  61.       Left            =   105
  62.       TabIndex        =   2
  63.       Top             =   210
  64.       Width           =   2685
  65.    End
  66. Attribute VB_Name = "Form1"
  67. Attribute VB_Creatable = False
  68. Attribute VB_Exposed = False
  69. Option Explicit
  70. Private Sub Command1_Click()
  71.    ' Set the blocking flag according to
  72.    ' user input.
  73.    Time1.Blocking = Check1.Value
  74.    ' Don't allow the user to get the
  75.    ' time again until we're done.
  76.    Command1.Enabled = False
  77.    On Error Resume Next
  78.    ' Attempt to get the system time from
  79.    ' a time server.
  80.    Time1.GetTime
  81.    ' Is there a real error?
  82.    If (Err <> 0 And Err <> 10035) Then
  83.       ' Show the user.
  84.       MsgBox Error
  85.       Command1.Enabled = True
  86.       Exit Sub
  87.       End If
  88.    ' If we used blocking, then we already
  89.    ' have the time (no error).
  90.    On Error GoTo 0
  91.    If (Time1.Blocking = True) Then
  92.       Label1.Caption = Time1.GMTTime
  93.       Command1.SetFocus
  94.       End If
  95.    End Sub
  96. Private Sub Time1_Done(ErrorCode As Integer)
  97.    ' We have the time now, display it and allow
  98.    ' the user to press the get time button again.
  99.    Command1.Enabled = True
  100.    Command1.SetFocus
  101.    Label1.Caption = Time1.GMTTime
  102.    End Sub
  103.